﻿using Hippo.Framework.Model;

namespace Hippo.Console.Lib
{
    public class RunSpecificationBuilder
    {
        private readonly IFileSystemWrapper fsw;

        public RunSpecificationBuilder(IFileSystemWrapper fsw)
        {
            this.fsw = fsw;
        }

        public RunSpecification Build(string[] scriptFiles)
        {
            var result = new RunSpecification();

            foreach (var scriptPath in scriptFiles)
            {
                if (fsw.FileExists(scriptPath))
                {
                    var scriptCode = fsw.ReadAllText(scriptPath);
                    result.AddScenario(new TestScenario(scriptPath, ScriptLanguage.Python, scriptCode));
                }
                else
                {
                    System.Console.Out.WriteLine("Script path {0} does not exist", scriptPath);
                }
            }

            return result;
        }
    }
}
